<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh" >
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>消息通知发送</title>
    <link href="../static/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../static/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="../static/css/style.css" rel="stylesheet"/>
    <link href="../static/css/login.min.css" rel="stylesheet"/>
    <link href="../static/ruoyi/css/ry-ui.css" rel="stylesheet"/>
    <link rel="../shortcut icon" href="favicon.ico"/>
    <style type="text/css">
        .signin-panel{
            width: 65%;
            margin: 5% 13%;
        }
        .body{
        	background-color:#696969;
        }
    </style>
</head>
<body class="body">
<script>
</script>
<input id="userId" name="userId" type="hidden" value="1" />
<section class="section-content">
   <div class="signin-panel">

    <div class="row">
        <div class="col-md-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>消息通知编辑</h5>
                </div>
                <div class="ibox-content">

                    <div class="main-content">
                        <form id="adviseSendForm" class="form-horizontal">
                            <div class="row">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">通知发送者：</label>
                                        <div class="col-sm-8">
                                            <input id="s" name="adviseSender" placeholder="${user.userId} (${user.name})" class="form-control" type="text" disabled="disabled">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">通知标题：</label>
                                        <div class="col-sm-8">
                                            <input name="adviseTitle" class="form-control" type="text"  placeholder="请输入通知标题">
                                        </div>
                                    </div>
                            </div>
                            <div class="row">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">接收者编号：</label>
                                        <div class="col-sm-8">
                                            <input id="text" name="adviseReceviser" placeholder="请输入接收者编号" class="form-control" type="text">
                                        </div>
                                    </div>
                            </div>
                            <div class="row">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">通知类型:</label>
                                        <div class="col-sm-5">
                                            <div class="input-group" style="width: 100%">
                                                <select name="adviseType" class="form-control m-b">
                                                    <option value="1">1&nbsp;(设备异常通知)</option>
                                                    <option value="2">2&nbsp;(购买通知)</option>
                                                    <option value="3">3&nbsp;(购买申请通知)</option>
                                                    <option value="4">4&nbsp;(生产申请)</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">通知内容:</label>
                                        <div class="col-sm-8">
                                            <textarea rows="15" name="adviseContent" class="form-control"  style="resize:none" ></textarea>
                                        </div>
                                    </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="btn-group pull-right" role="group">
                                        <button id="adviseSubmitBtn" class="btn btn-primary" type="submit">发送</button>
                                        <button class="btn btn-danger" type="reset">重置</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</section>
<script src="../static/js/jquery.min.js"></script>
<script src="../static/ajax/libs/validate/jquery.validate.min.js"></script>
<script src="../static/ajax/libs/validate/messages_zh.min.js"></script>
<script src="../static/js/bootstrap.min.js"></script>
<script src="../static/ajax/libs/layer/layer.min.js"></script>
<script src="../static/ajax/libs/blockUI/jquery.blockUI.js"></script>
<script src="../static/ruoyi/js/ry-ui.js"></script>
<script>


    $(function() {
        validateRule();
    });

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        var userId="${user.userId}";
        $("#adviseSendForm").validate({
            rules: {
            	adviseSender:{
            		required:true,
            	},
            	adviseTitle: {
                    required: true,
                },
                adviseReceviser: {
                    required: true,
                    number:true
                },
                adviseContent: {
                    required: true,
                    maxlength : 255
                }
            },
            submitHandler: function() {
                //此处写请求后台的ajax
                let data = $("#adviseSendForm").serialize();//先将表单对象序列化，因为对象不能在网络上传输，所以需要将对象序列化
                $.ajax({
                	url:"../advise/sendAdviseRecord.do?adviseSender=${user.userId}",
                	type:"POST",
                	data : data,
                	dataType : "json",
                    success : function (response) {
                    	if(response.Result=="failed"){
                    		layer.alert(response.message, {icon: 2, title:'提示'});
                    	}else{
                        	layer.alert(response.message, {icon: 1, title:'提示'});
                        }
                    }
                });
                
            }
        })
    }

</script>
</body>
</html>